Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

XFuNTreeAbstractIterator.h

Go to the documentation of this file.
00001 /*! \file 
00002  * X-Forge Util <br>
00003  * Copyright 2000-2003 Fathammer Ltd
00004  * 
00005  * \brief N-Tree abstract iterator template
00006  *
00007  * $Id: XFuNTreeAbstractIterator.h,v 1.4 2003/03/20 13:19:59 jetro Exp $
00008  * $Date: 2003/03/20 13:19:59 $
00009  * $Revision: 1.4 $
00010  */
00011 
00012 #ifndef XFUNTREEABSTRACTITERATOR_H_INCLUDED
00013 #define XFUNTREEABSTRACTITERATOR_H_INCLUDED
00014 
00015 template<class T> class XFuNTree;
00016 template<class T> class XFuNTreeNode;
00017 
00018 
00019 template<class T> class XFuNTreeAbstractIterator
00020 {
00021 public:
00022     
00023     //! Checks if the nodes pointed by two iterators are inequal.
00024     /*! \return 1 if inequal, 0 otherwise.
00025      */
00026     INT operator!=(const XFuNTreeAbstractIterator &aRef) const;
00027     
00028     //! Checks if the nodes pointed by two iterators are equal.
00029     /*! \return 1 if equal, 0 otherwise.
00030      */
00031     INT operator==(const XFuNTreeAbstractIterator &aRef) const;
00032 
00033     //! Returns the amount of allocated child nodes.
00034     /*! \return Amount of allocated child nodes, 0 if node is not valid
00035      */
00036     UINT32 size() const;
00037 
00038     //! Returns information about the validity of the node.
00039     /*! \return 1 if the node is valid, 0 otherwise.
00040      */
00041     INT isValid() const;
00042     
00043     //! Returns information about the validity of the Nth child node.
00044     /*!
00045      * \param aIndex Index of child node.
00046      * \return 1 if the node is valid, 0 otherwise.
00047      */
00048     INT isValid(const UINT32 aIndex) const;
00049     
00050     //! Checks whether the node is a leaf node.
00051     /*! \return 1 if the node is a leaf node, 0 otherwise
00052      */
00053     INT isLeaf() const;
00054     
00055     //! Sets the internal data of a node.
00056     /*! \return 1 if the addition succeeded, 0 if an error occured
00057      */
00058     INT setData(T aNewData);
00059     
00060     //! Returns the internal data of a node.
00061     /*!
00062      * \return Internal data of a node
00063      */
00064     T getData() const;
00065 
00066 protected:
00067     
00068     //! Number of child nodes in each node.
00069     UINT32 mChildNodes;
00070 
00071     //! Current node.
00072     XFuNTreeNode<T> *mNode;
00073 
00074     //! Creates an empty iterator.
00075     XFuNTreeAbstractIterator();
00076     //! Creates an iterator pointing to a node.
00077     XFuNTreeAbstractIterator(XFuNTreeNode<T> *aNode, const UINT32 aChildNodes);
00078 
00079     friend class XFuNTree<T>;
00080 };
00081 
00082 
00083 template<class T> 
00084 INT XFuNTreeAbstractIterator<T>::operator!=(const XFuNTreeAbstractIterator &aRef) const
00085 {
00086     if (mNode != aRef.mNode)
00087         return 1;
00088     else
00089         return 0;
00090 }
00091 
00092 
00093 template<class T> 
00094 INT XFuNTreeAbstractIterator<T>::operator==(const XFuNTreeAbstractIterator &aRef) const
00095 {
00096     if (mNode == aRef.mNode)
00097         return 1;
00098     else
00099         return 0;
00100 }
00101 
00102 
00103 template<class T> UINT32 XFuNTreeAbstractIterator<T>::size() const
00104 {
00105     if (mNode != NULL)
00106         return mNode->size();
00107     else
00108         return 0;
00109 }
00110 
00111 
00112 template<class T> INT XFuNTreeAbstractIterator<T>::isValid() const
00113 {
00114     if (mNode != NULL)
00115         return 1;
00116     else
00117         return 0;
00118 }
00119 
00120 
00121 template<class T> 
00122 INT XFuNTreeAbstractIterator<T>::isValid(const UINT32 aIndex) const
00123 {
00124     if (mNode != NULL)
00125         return mNode->isValid(aIndex);
00126     else
00127         return 0;
00128 }
00129 
00130 
00131 template<class T> INT XFuNTreeAbstractIterator<T>::isLeaf() const
00132 {
00133     if (mNode != NULL)
00134         return mNode->isLeaf();
00135     else
00136         return 0;
00137 }
00138 
00139 
00140 template<class T> INT XFuNTreeAbstractIterator<T>::setData(T aNewData)
00141 {
00142     if (mNode != NULL)
00143     {
00144         mNode->setData(aNewData);
00145         return 1;
00146     }
00147     else
00148         return 0;
00149 }
00150 
00151 
00152 template<class T> T XFuNTreeAbstractIterator<T>::getData() const
00153 {
00154     return mNode->getData();
00155 }
00156 
00157 
00158 template<class T> XFuNTreeAbstractIterator<T>::XFuNTreeAbstractIterator()
00159 {
00160     mNode = NULL;
00161     mChildNodes = 0;
00162 }
00163 
00164 
00165 template<class T> XFuNTreeAbstractIterator<T>::XFuNTreeAbstractIterator(XFuNTreeNode<T> *aNode, 
00166                                                       const UINT32 aChildNodes)
00167 {
00168     mNode = aNode;
00169     mChildNodes = aChildNodes;
00170 }
00171 
00172 
00173 #endif // !XFUNTREEABSTRACTITERATOR_H_INCLUDED

   
X-Forge Documentation
Confidential
Copyright © 2002-2003 Fathammer
   
Documentation generated
with doxygen
by Dimitri van Heesch